<template>
	<!-- addpersonnel添加人员 -->
	<view class="a_wp">
		<uni-card :border="false" spacing="5px 5px" padding="0" :is-shadow="false" is-full>
			<text class="message"> 提交后，员工需要在设置中进入【店铺确认】确认即可</text>
		</uni-card>
		<view class="a_item">
			<view class="a_title">会员ID:</view>
			<input type="text" v-model="info.id" class="a_input" placeholder="请输入完整会员ID">
			<button size="mini" type="default" @click="seach">查询</button>
		</view>
		<view class="a_item">
			<view class="a_title">姓名:</view>
			<view class="a_text">{{info.nickname}}</view>
		</view>
		<view class="a_item">
			<view class="a_title">电话:</view>
			<view class="a_text">{{info.mobile}}</view>
		</view>
		<view class="fbt" @click="onshumbit">提交</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid: '',
				info: {
					id: '',
					nickname: '',
					mobile: ''
				}
			}
		},
		onLoad(options) {
			this.uid = options.uid;
		},
		methods: {
			onshumbit() {
				if(this.info.nickname=='' || this.info.mobile==''){
					this.$api.msg('请先查询核对信息');
					return;
				}
				uni.showModal({
					title: '提示',
					content: '是否确认授权？',
					success: res=> {
						console.log(this.info.id)
						if (res.confirm) {
							this.$axios('info/memberSave', 'POST', 'supplier', {
								uid: this.uid,
								mid: this.info.id
							}).then(res => {
								if (res.data.code == 200) {
									this.$api.msg(res.data.data);
									setTimeout(() => {
										this.$navBack();
									}, 500)
								}
							})
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			},
			seach() {
				if (this.info.id == '') {
					this.$api.msg('请填写会员ID');
					return;
				}
				this.$axios('info/memberInfo', 'POST', 'supplier', {
					uid: this.uid,
					mid: this.info.id
				}).then(res => {
					if (res.data.code == 200) {
						this.info = res.data.data;
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		color: $font-color-dark;
	}

	.a_item {
		display: flex;
		align-items: center;
		padding: 20upx;
	}

	.a_title {
		font-weight: bold;
	}

	.a_input,
	.a_text {
		color: $font-color-base;
		padding: 0 20upx;
	}

	.a_input {
		flex: 1;
		font-size: 26upx;
	}
</style>